import UIKit

/*
删除排序数组中的重复项
 中文：https://leetcode-cn.com/problems/remove-duplicates-from-sorted-array/
 英文：https://leetcode.com/problems/remove-duplicates-from-sorted-array/
*/

class Duplicates {
    func removeDuplicates (_ nums: inout [Int]) -> Int {
        guard nums.count > 1 else {
            return nums.count
        }
        var count = 1
        for i in 1..<nums.count {
            if nums[i] != nums[i-1] {
                nums[count] = nums[i]
                count += 1
            }
        }
        
        return count
    }
}
var nums1 = [0,0,1,1,1,2,2,3,3,4]
let duplicates: Duplicates = Duplicates()
duplicates.removeDuplicates(&nums1)
nums1

